package com.zhanghe.study.springboot.controller;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Future;

/**
 * @author zh
 * @date 2021/8/31 16:46
 */
@RestController
public class TestAsyncController {

    @Async
    @RequestMapping("/testAysnc")
    public Future<String> test() {
        String name = Thread.currentThread().getName();
        System.out.println(name);
        return AsyncResult.forValue(name);
    }
}
